<%--
  Created by IntelliJ IDEA.
  User: LLg
  Date: 2022/11/23
  Time: 20:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/layui/css/layui.css">
    <script src="${pageContext.request.contextPath}/statics/layui/layui.js"></script>
</head>
<body>
<form class="layui-form" action="add" method="post" lay-filter="formUpdate">
    <div class="layui-form-item">
        <label class="layui-form-label">角色名称</label>
        <div class="layui-input-block">
            <input type="text" name="role_name" lay-verify="required"  placeholder="请输入角色名称" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">权限字符</label>
            <div class="layui-input-block">
                <input type="text" name="role_key" lay-verify="required"  placeholder="请输入权限字符" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">显示顺序</label>
            <div class="layui-input-block">
                <input type="text" name="role_sort" lay-verify="required"  placeholder="请输入显示顺序" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="remark" lay-verify="required"  placeholder="请输入备注" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
    </div>
    </div>
    </div>
</form>
</body>
<script>
    layui.use(['form', 'jquery','layer'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        form.on('submit(demo1)', function (data) {

            var formUpdate = form.val("formUpdate");
            $.post("${pageContext.request.contextPath}/sysRole/add", formUpdate, function (result) {
                if (result) {
                    layer.msg("新增成功", function () {
                        parent.location.reload();
                        parent.layer.closeAll();
                    })
                } else {
                    layer.msg("新增失败")
                }
            })
            return false;
        });
    });
</script>
</html>
